package com.me.libgdx_test;

import java.util.ArrayList;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.me.libgdx_test.ClassUnlockablePrototypes.UnlockFactory;

//This class creates an achievement object that can be attached to any stage
public class ClassAchievementEnd extends AbstractClassAchievement{
	
	private int previous_level, previous_gold, previous_honor;
	ClassAchievementEnd(ActivityMain game, Point dimensions, int previous_level, int previous_honor, int previous_gold){
		super(game,dimensions);

		this.previous_level = previous_level;
		this.previous_gold = previous_gold;
		this.previous_honor = previous_honor;
		
		populate_achievement_object();
	}
	private void populate_achievement_object(){
		
		int x_space = dimensions.x/50;
		int y_space = dimensions.y/40;
		int x_margin = 0;
		int y_margin = 0;
		
		//achievement_group.setPosition(36*dimensions.x/100, 24*dimensions.y/100);
		
		//Group inner_group = new Group();
		
		//inner_group.setPosition(achievement_group.getX() + x_space, achievement_group.getY() + y_space);
		
		//market_item_image.setPosition(dimensions.x/10, element_y);
		level_icon.setPosition(x_space*10, y_margin);
		level_icon.setSize(dimensions.x/30,dimensions.x/30);
		achievement_group.addActor(level_icon);
		
		x_margin += level_icon.getX() + level_icon.getWidth() + x_space;
		
		int level_difference = current_level - previous_level;
		final Label level_label = new Label(String.valueOf(current_level) + (level_difference == 0?"":" (+"+level_difference+")"), skin.get_skin());
		level_label.setFontScale(1);
		//description_label.setWrap(true);
		//description_label.setPosition(location.x+padding, element_y);
		level_label.setPosition(x_margin + level_label.getX(), y_margin + level_label.getY());
		level_label.setSize(dimensions.x/30,dimensions.x/30);
		achievement_group.addActor(level_label);
		
		x_margin += level_label.getWidth() + x_space/2;
		//x_margin = 0;
		//y_margin -= level_icon.getHeight() + y_space;
		
		//market_item_image.setPosition(dimensions.x/10, element_y);
		//level_icon.setPosition(location.x, element_y);
		honor_icon.setPosition(x_margin + honor_icon.getX(), y_margin + honor_icon.getY());
		honor_icon.setSize(dimensions.x/30,dimensions.x/30);
		achievement_group.addActor(honor_icon);
		
		x_margin += honor_icon.getWidth() + x_space;
		
		int honor_difference = current_honor - previous_honor;
		final Label honor_label = new Label(String.valueOf(current_honor) + (honor_difference == 0?"":" (+"+honor_difference+")"), skin.get_skin());
		honor_label.setFontScale(1);
		//description_label.setWrap(true);
		//description_label.setPosition(location.x+padding, element_y);
		honor_label.setPosition(x_margin + honor_label.getX(), y_margin + honor_label.getY());
		honor_label.setSize(dimensions.x/30,dimensions.x/30);
		achievement_group.addActor(honor_label);
		
		x_margin += honor_label.getWidth() + x_space/2;
		//x_margin = 0;
		//y_margin -= honor_icon.getHeight() + y_space;
		
		//market_item_image.setPosition(dimensions.x/10, element_y);
		//level_icon.setPosition(location.x, element_y);
		gold_icon.setPosition(x_margin + gold_icon.getX(), y_margin + gold_icon.getY());
		gold_icon.setSize(dimensions.x/30,dimensions.x/30);
		achievement_group.addActor(gold_icon);
		
		x_margin += gold_icon.getWidth() + x_space;
		
		int gold_difference = previous_gold;
		final Label gold_label = new Label(String.valueOf(current_gold) + (gold_difference == 0?"":" (+"+gold_difference+")"), skin.get_skin());
		gold_label.setFontScale(1);
		//description_label.setWrap(true);
		//description_label.setPosition(location.x+padding, element_y);
		gold_label.setPosition(x_margin + gold_label.getX(), y_margin + gold_label.getY());
		gold_label.setSize(dimensions.x/30,dimensions.x/30);
		achievement_group.addActor(gold_label);

	}
	public Group get_achievement_group(){
		return achievement_group;
	}
}
